export function makeRequiredRule() {
  return {
    type: 'Required', field: 'formCreate$required', title: '是否必填'
  };
}

export const localeProps = (t, prefix, rules) => {
  return rules.map(rule => {
    if (rule.field === 'formCreate$required') {
      rule.title = t('validate.required') || rule.title;
    } else if (rule.field && rule.field !== '_optionType') {
      rule.title = t('com.' + prefix + '.' + rule.field) || rule.title;
    }
    if (rule.type === 'template' && Array.isArray(rule.children) && rule.children.length > 0) {
      rule.children = localeProps(t, prefix, rule.children);
    }
    return rule;
  })
}
